<?php
//$a = [1, 2, 3, 4];
//foreach ($a as $k => $v) {
//    echo $k . '----' . $v . '<br/>';
//}

//$user = [
//    'username' => '电信',
//    'score' => 100,
//    'id' => 10001
//];
//foreach ($user as $key => $val) {
//    echo $key . '----' . $val . '<br/>';
//}
// 数据库获取，转化成以下形式
$articles = [
    [
        'id' => 1,
        'title' => '掌握了数组就掌握了PHP的开发精髓'
    ],
    [
        'id' => 2,
        'title' => '多维数组在开发中经常使用'
    ]
];
//foreach ($articles as $key => $val){
//    echo $val['title'] . '<br/>';
//}
?>

<html>
<head></head>
<body>
    <ul>
        <?php foreach ($articles as $art):?>
            <li><a href="/detail.php?id=<?php echo $art['id'];?>"><?php echo $art['title'];?></a></li>
        <?php endforeach;?>
    </ul>
</body>
</html>